/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ControlLayer;
import ModelLayer.*;
import DBLayer.*;
import java.util.ArrayList;

/**
 *
 * @author Henrik
 */
public class CtrSupplier {
    public CtrSupplier(){

    }

    public ArrayList findAllSuppliers(boolean retrieveAssociation)
    {
        IFDBSupplier dbSupp = new DBSupplier();
        ArrayList allSupp = new ArrayList();
        allSupp = dbSupp.getAllSuppliers(retrieveAssociation);
        return allSupp;
    }

    public Supplier findSupplierById(int id, boolean retrieveAssociation)
    {
        IFDBSupplier dbSupp = new DBSupplier();
        return dbSupp.findSupplierById(id, retrieveAssociation);
    }

    public Supplier findSupplierByName(String name, boolean retrieveAssociation){
        IFDBSupplier dBSupplier = new DBSupplier();
        return dBSupplier.findSupplierByName(name, retrieveAssociation);
    }

    public int insertSupplier(Supplier supplier){
        IFDBSupplier dbSupp = new DBSupplier();
        return dbSupp.insertSupplier(supplier);
    }

    public int updateSupplier(int id, String name, String street, int streetNo,
            String country, String phoneNo, String email){

        IFDBSupplier dbSupp = new DBSupplier();
        Supplier supp = new Supplier();
        supp.setId(id);
        supp.setName(name);
        supp.setStreet(street);
        supp.setStreetNo(streetNo);
        //supp.setZipCode(zipCode);
        supp.setCountry(country);
        supp.setPhoneNo(phoneNo);
        supp.setEmail(email);
        return dbSupp.updateSupplier(supp);
    }

    public int deleteSupplier(int id){
        IFDBSupplier dbSupp = new DBSupplier();
        return dbSupp.deleteSupplier(id);
    }
}
